import request from "../utils/requestUtil.js";


/**
 *  查询当前一共有哪些队伍
 * @returns
 */
export async function teamListApi() {
    return await request.post('/api/team/list')

}


/**
 *  加入队伍
 * @param teamName  队伍名称
 * @returns {
 */
export async function joinTeamApi(teamName) {
    return await request.post('api/user-team/joinTeam', {},
        {
            params: {
                teamName: teamName,
            }
        }
    )
}


/**
 * 查询当前用户加入的队伍
 * @returns
 */
export async function selectUserTeam() {
    return await request.get('api/user-team/selectUserTeamByUserId')
}


/**
 *  退出队伍
 * @param teamName  队伍名称
 */
export async function exitTeamApi(teamName) {
    return await request.post('api/user-team/exitTeam', {}, {
        params: {
            teamName: teamName
        }
    })
}


export async function findTeamById(teamId) {
    return await request.get('api/team/findTeamById', {
        params: {
            teamId: teamId
        }
    })
}


/**
 * 根据队伍id查询队伍成员
 * @param teamId      队伍id
 */
export async function selectUserByTeamId(teamId) {
    return await request.get('api/user-team/selectTeamByUserId', {
        params: {
            teamId: teamId
        }
    })
}



export async function updateTeamApi(teamQuery) {
    return await request.post('api/team/updateTeam', teamQuery )
}


export async function deleteTeamApi(teamName){
    return await request.post('api/team/deleteTeam',{},{
        params:{
            teamName:teamName
        }
    })
}